package com.jsbs.iam.user.controller;

import com.jsbs.iam.common.core.dto.Result;
import com.jsbs.iam.common.core.utils.Json;
import com.jsbs.iam.common.core.utils.StringUtils;
import com.jsbs.iam.user.constant.Constants;
import com.jsbs.iam.user.dto.OrgInfoAddDto;
import com.jsbs.iam.user.dto.OrgInfoDeleteDto;
import com.jsbs.iam.user.dto.OrgInfoQueryDto;
import com.jsbs.iam.user.entity.IamOrgTypeExtendedField;
import com.jsbs.iam.user.service.OrgInfoService;
import com.jsbs.iam.user.vo.OrgInfoVo;
import com.jsbs.iam.user.vo.OrgThreeInfo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @BelongsProject: iam
 * @BelongsPackage: com.jsbs.iam.user.controller
 * @Author: WangJiYuan
 * @Description: TODO
 * @Version: 2022-12-12  19:17
 */
@Slf4j
@RestController
@RequestMapping("/iam/user/orgInfo")
public class OrgInfoController extends BaseController {

    private static final Logger LOGGER = LoggerFactory.getLogger(OrgInfoController.class);

    @Autowired
    private OrgInfoService orgInfoService;

    private static final String ADMIN_USER = "admin";

    /**获取组织树
     * @return
     */
    @PostMapping("/getOrgTypeInfo")
    public Result selectOrgTypeInfo(HttpServletRequest httpServletRequest, @RequestBody OrgInfoQueryDto orgInfoQueryDto) {
        log.info("Route=>OrgInfoController method=>selectOrgTypeInfo 查询组织树结构,入参：{}", Json.toJsonString(orgInfoQueryDto));
        try {
            // todo  wjy  临时获取companyCode和userCode方法
            String companyCode = httpServletRequest.getHeader(Constants.COMPANY_CODE);
            String userCode = httpServletRequest.getHeader(Constants.USER_CODE);
            String adminRoleCode = httpServletRequest.getHeader(Constants.ADMIN_ROLE_CODE);
            companyCode = "000001";
            userCode = "admin";//0000000049 admin
            adminRoleCode = "JS0030";
            if (StringUtils.isEmpty(companyCode)) {
                log.warn("Route=>OrgInfoController method=>selectOrgTypeInfo 获取组织树，当前登录人归属租户信息异常");
                return Result.failWithMsg("登录人归属租户信息异常");
            }
            if (StringUtils.isEmpty(userCode)) {
                log.warn("Route=>OrgInfoController method=>selectOrgTypeInfo 获取组织树，当前登录人信息异常");
                return Result.failWithMsg("登录人信息异常");
            }
            if (!ADMIN_USER.equals(userCode) && StringUtils.isEmpty(adminRoleCode)) {
                log.warn("Route=>OrgInfoController method=>selectOrgTypeInfo 获取组织树，当前登录人角色信息异常");
                return Result.failWithMsg("登录人角色信息异常");
            }
            orgInfoQueryDto.setCompanyCode(companyCode);
            orgInfoQueryDto.setAdminRoleCode(adminRoleCode);

            if (StringUtils.isEmpty(orgInfoQueryDto.getOrgTypeCode())) {
                log.warn("Route=>OrgInfoController method=>selectOrgTypeInfo 查询组织树结构组织类型为空");
                return Result.failWithMsg("组织类型为空");
            }
            // 获取组织树信息
            List<OrgThreeInfo> threeInfos = new ArrayList<>();
            if (ADMIN_USER.equals(userCode)) {
                //超管
                threeInfos = orgInfoService.selectOrgTypeInfo(orgInfoQueryDto);
            } else {
                //普管获取组织树信息
                threeInfos = orgInfoService.selectOrgTypeInfoRestrict(orgInfoQueryDto);
            }

            return new Result(Result.SUCCESS, "查询组织类型成功", threeInfos);
        } catch (Exception e) {
            LOGGER.error("Route==>OrgInfoController method=>selectOrgTypeInfo 查询组织树结构异常，入参：{}，异常：{}", Json.toJsonString(orgInfoQueryDto), e);
        return handleException(e);
    }

    }

    /**
     * 获取所有组织树数据
     * @param httpServletRequest
     * @return
     */
    @PostMapping("/getOrgThreeAllInfo")
    public Result getOrgThreeAllInfo(HttpServletRequest httpServletRequest) {
        log.info("Route=>OrgInfoController method=>getOrgThreeAllInfo 获取所有组织树数据，入参：{}", "");
        try {
            // todo  wjy  临时获取companyCode方法
            String companyCode = httpServletRequest.getHeader(Constants.COMPANY_CODE);
            companyCode = "000001";
            if (StringUtils.isEmpty(companyCode)) {
                log.warn("Route=>OrgInfoController method=>getOrgThreeAllInfo 获取所有组织树数据，当前登录人归属租户信息异常");
                return Result.failWithMsg("登录人归属租户信息异常");
            }
            // 获取所有组织树数据
            List<OrgThreeInfo> threeInfos = orgInfoService.getOrgThreeAllInfo(companyCode);
            return new Result(Result.SUCCESS, "获取所有组织树数据成功", threeInfos);
        } catch (Exception e) {
            LOGGER.error("Route==>OrgInfoController method=>getOrgThreeAllInfo 获取所有组织树数据异常，入参：{}，异常：{}", "", e);
            return handleException(e);
        }

    }

    /**
     * 获取组织类型扩展字段数据
     * @param orgTypeCode
     * @return
     */
    @PostMapping("/getOrgTypeExtend")
    public Result getOrgTypeExtend(HttpServletRequest httpServletRequest, @RequestParam("orgTypeCode") String orgTypeCode) {
        log.info("Route=>OrgInfoController method=>getOrgTypeExtend 获取组织类型扩展字段数据：{}", orgTypeCode);
        try {
            // todo  wjy  临时获取companyCode方法
            String companyCode = httpServletRequest.getHeader(Constants.COMPANY_CODE);
            companyCode = "000001";
            if (StringUtils.isEmpty(companyCode)) {
                log.warn("Route=>OrgInfoController method=>addOrgType 获取组织类型扩展字段数据，当前登录人归属租户信息异常");
                return Result.failWithMsg("登录人归属租户信息异常");
            }
            if (StringUtils.isEmpty(orgTypeCode)) {
                log.info("获取组织类型扩展字段数据失败,参数非法{}", orgTypeCode);
                return Result.failWithMsg("组织类型为空");
            }
            List<IamOrgTypeExtendedField> orgTypeExtendedFields = orgInfoService.getOrgTypeExtend(orgTypeCode,companyCode);

            return new Result(Result.SUCCESS, "组织类型扩展字段数据成功", orgTypeExtendedFields);
        } catch (Exception e) {
            LOGGER.error("Route==>OrgInfoController method=>getOrgTypeExtend 获取组织类型扩展字段数据异常，入参：{}，异常：{}", orgTypeCode, e);
            return handleException(e);
        }
    }


    /**
     * 新增组织层级
     * @param orgInfoAddDto
     * @return
     */
    @PostMapping("/addOrgInfo")
    public Result addOrgInfo(HttpServletRequest httpServletRequest,@RequestBody OrgInfoAddDto orgInfoAddDto) {
        log.info("Route=>OrgInfoController method=>addOrgInfo 新增组织层级：{}", Json.toJsonString(orgInfoAddDto));
        try {
            // todo  wjy  临时获取companyCode和userCode方法
            String companyCode = httpServletRequest.getHeader(Constants.COMPANY_CODE);
            //String userCode = httpServletRequest.getHeader(Constants.USER_CODE);
            String userName = (String) httpServletRequest.getSession().getAttribute("userName");
            companyCode = "000001";
            //userCode = "001001";
            userName = "wjy";
            if (StringUtils.isEmpty(companyCode)) {
                log.warn("Route=>OrgInfoController method=>addOrgInfo 新增组织层级，当前登录人归属租户信息异常");
                return Result.failWithMsg("登录人归属租户信息异常");
            }
            /*if (StringUtils.isEmpty(userCode)) {
                log.warn("Route=>OrgInfoController method=>addOrgInfo 新增组织层级，当前登录人信息异常");
                return Result.failWithMsg("登录人信息异常");
            }*/
            if (StringUtils.isEmpty(userName)) {
                log.warn("Route=>OrgInfoController method=>addOrgInfo 新增组织层级，当前登录人信息异常");
                return Result.failWithMsg("登录人信息异常");
            }
            orgInfoAddDto.setCompanyCode(companyCode);
            orgInfoAddDto.setCreatePerson(userName);

            if (StringUtils.isEmpty(orgInfoAddDto.getOrgTypeCode())) {
                log.info("新增组织层级失败,参数非法{}", orgInfoAddDto.getOrgTypeCode());
                return Result.fail(Result.FAIL, "组织类型编码不可为空");
            }
            if (StringUtils.isEmpty(orgInfoAddDto.getOrgName())) {
                log.info("新增组织层级失败,参数非法{}", orgInfoAddDto.getOrgName());
                return Result.fail(Result.FAIL, "组织名称不可为空");
            }
            if (orgInfoAddDto.getOrgLevel() == null) {
                log.info("新增组织层级失败,参数非法{}", orgInfoAddDto.getOrgLevel());
                return Result.fail(Result.FAIL, "组织层级不可为空");
            }
            if (orgInfoAddDto.getOrgIndex() == null) {
                log.info("新增组织层级失败,参数非法{}", orgInfoAddDto.getOrgIndex());
                return Result.fail(Result.FAIL, "组织排序不可为空");
            }
            //新增组织数据校验扩展字段规则
            if (CollectionUtils.isNotEmpty(orgInfoAddDto.getExtendData())) {
                //"0" 新增
                Result msg = verifyExtendData(orgInfoAddDto, "0");
                if (msg.getCode() == 9) {
                    log.info("新增组织层级失败,参数非法{}:::" + msg.getMsg(), orgInfoAddDto.getExtendData());
                    return Result.fail(Result.FAIL, msg.getMsg());
                }
            }
            orgInfoService.addOrgInfo(orgInfoAddDto);

            return new Result(Result.SUCCESS, "新增组织层级成功");
        } catch (Exception e) {
            LOGGER.error("Route==>OrgInfoController method=>addOrgInfo 新增组织层级异常，入参：{}，异常：{}", Json.toJsonString(orgInfoAddDto), e);
            return handleException(e);
        }
    }

    /**
     * 组织数据校验扩展字段规则
     *
     * @param orgInfoAddDto
     * @param s  操作类型 0 :新增  1 :修改
     * @return
     */
    private Result verifyExtendData(OrgInfoAddDto orgInfoAddDto, String s) {
        String msgStr = "";
        if (CollectionUtils.isNotEmpty(orgInfoAddDto.getExtendData())) {
            for (Map<String, String> extendDatum : orgInfoAddDto.getExtendData()) {
                if (MapUtils.isNotEmpty(extendDatum)) {
                    Set<String> keys = extendDatum.keySet();
                    for (String fieldId : keys) {
                        //查询对应字段详细数据
                        IamOrgTypeExtendedField extendedField = orgInfoService.getExtendInfo(fieldId,orgInfoAddDto.getCompanyCode());
                        //取出填写的数据
                        String fieldData = extendDatum.get(fieldId);
                        //判断是否可以为空
                        //允许为空 0:不允许为空  1:允许为空
                        Integer isNull = extendedField.getIsNull();
                        //0:不允许为空
                        if (isNull != null && isNull == 0) {
                            if (StringUtils.isEmpty(fieldData)) {
                                msgStr = extendedField.getFieldName() + "不能为空";
                                return Result.failWithMsg(msgStr);
                            } else {
                                //校验字段类型
                                if (!verifyType(extendedField.getFieldType(), fieldData)) {
                                    msgStr = extendedField.getFieldName() + "不能输入非" + extendedField.getFieldType() + "类型数据";
                                    return Result.failWithMsg(msgStr);
                                }
                                //校验字段长度
                                if (fieldData.length() > extendedField.getFieldLength()) {
                                    msgStr = extendedField.getFieldName() + "输入长度大于" + extendedField.getFieldLength();
                                    return Result.failWithMsg(msgStr);
                                }
                                //校验是否唯一
                                //是否唯一 0:不允许唯一  1:允许唯一
                                Integer isSole = extendedField.getIsSole();
                                if (isSole != null && isSole == 1) {
                                    if ("0".equals(s)) {
                                        //新增
                                        //校验扩展字段唯一性
                                        int count = orgInfoService.verifyIsSole(fieldId, fieldData, orgInfoAddDto.getCompanyCode());
                                        if (count > 0) {
                                            msgStr = extendedField.getFieldName() + "必须唯一, 请重新输入";
                                            return Result.failWithMsg(msgStr);
                                        }
                                    } else {
                                        //修改
                                        //校验是否修改数据
                                        String fieldInfo = orgInfoService.verifyFieldData(fieldId, orgInfoAddDto.getOrgCode(), orgInfoAddDto.getCompanyCode());
                                        if (StringUtils.isNotEmpty(fieldInfo) && !fieldData.equals(fieldInfo)) {
                                            int count = orgInfoService.verifyIsSole(fieldId, fieldData, orgInfoAddDto.getCompanyCode());
                                            if (count > 0) {
                                                msgStr = extendedField.getFieldName() + "必须唯一, 请重新输入";
                                                return Result.failWithMsg(msgStr);
                                            }
                                        }
                                    }

                                }
                            }
                        }
                    }
                }
            }
        }
        return Result.success();
    }

    /**
     * 校验字段类型
     * @param type
     * @param fieldData
     * @return
     */
    public boolean verifyType(String type, String fieldData) {
        if (StringUtils.isNotEmpty(fieldData)) {
            if ("Integer".equals(type)) {
                return isNumeric(fieldData);
            } else {
                return true;
            }
        } else {
            return false;
        }
    }

    /**
     * 判断是否为数字
     * @param str
     * @return
     */
    public boolean isNumeric(String str)
    {
        Pattern pattern = Pattern.compile("[0-9]*");
        Matcher isNum = pattern.matcher(str);
        if( !isNum.matches() )
        {
            return false;
        }
        return true;
    }

    /**
     * 删除组织层级
     *
     * @param
     * @return
     */
    @PostMapping("/deleteOrgInfo")
    public Result deleteOrgInfo(HttpServletRequest httpServletRequest, OrgInfoDeleteDto deleteDto) {
        log.info("Route=>OrgInfoController method=>deleteOrgInfo 删除组织层级：{}", Json.toJsonString(deleteDto));
        try {
            // todo  wjy  临时获取companyCode和userCode方法
            String companyCode = httpServletRequest.getHeader(Constants.COMPANY_CODE);
            //String userCode = httpServletRequest.getHeader(Constants.USER_CODE);
            String userName = (String) httpServletRequest.getSession().getAttribute("userName");
            companyCode = "000001";
            //userCode = "001001";
            userName = "wjy";

            if (StringUtils.isEmpty(companyCode)) {
                log.warn("Route=>OrgInfoController method=>deleteOrgInfo 删除组织层级，当前登录人归属租户信息异常");
                return Result.failWithMsg("登录人归属租户信息异常");
            }
            /*if (StringUtils.isEmpty(userCode)) {
                log.warn("Route=>OrgInfoController method=>deleteOrgInfo 删除组织层级，当前登录人信息异常");
                return Result.failWithMsg("登录人信息异常");
            }*/
            if (StringUtils.isEmpty(userName)) {
                log.warn("Route=>OrgInfoController method=>deleteOrgInfo 删除组织层级，当前登录人信息异常");
                return Result.failWithMsg("登录人信息异常");
            }
            deleteDto.setCompanyCode(companyCode);
            deleteDto.setUpdatePerson(userName);

            if (StringUtils.isEmpty(deleteDto.getOrgCode())) {
                log.info("删除组织层级失败,参数非法{}", deleteDto.getOrgCode());
                return Result.fail(Result.FAIL, "组织编码不可为空");
            }
            //查询组织下用户数量
            int userCount = orgInfoService.getUserCount(deleteDto.getOrgTypeCode(), deleteDto.getOrgCode(),companyCode);
            //校验组织下是否有用户
            if (userCount > 0) {
                log.info("组织下用户数量", userCount);
                return Result.fail(Result.FAIL, "层级下面如果有用户，不可删除，需清空用户");
            }
            //删除组织层级
            orgInfoService.deleteOrgInfo(deleteDto);

            return new Result(Result.SUCCESS, "删除组织层级成功");
        } catch (Exception e) {
            LOGGER.error("Route==>OrgInfoController method=>deleteOrgInfo 删除组织层级异常，入参：{}，异常：{}", Json.toJsonString(deleteDto), e);
            return handleException(e);
        }
    }

    /***
     * 根据组织编码查询组织数据
     * @param orgInfoAddDto
     * @return
     */
    @PostMapping("/selectOrgInfo")
    public Result selectOrgInfo(HttpServletRequest httpServletRequest, @RequestBody OrgInfoAddDto orgInfoAddDto) {
        log.info("Route=>OrgInfoController method=>selectOrgInfo 根据组织编码查询组织数据：{}", Json.toJsonString(orgInfoAddDto));
        try {
            // todo  wjy  临时获取companyCode方法
            String companyCode = httpServletRequest.getHeader(Constants.COMPANY_CODE);
            companyCode = "000001";
            if (StringUtils.isEmpty(companyCode)) {
                log.warn("Route=>OrgInfoController method=>selectOrgInfo 根据组织编码查询组织数据，当前登录人归属租户信息异常");
                return Result.failWithMsg("登录人归属租户信息异常");
            }
            orgInfoAddDto.setCompanyCode(companyCode);

            if (StringUtils.isEmpty(orgInfoAddDto.getOrgTypeCode())) {
                log.info("据组织编码查询组织数据失败,参数非法{}", orgInfoAddDto.getOrgTypeCode());
                return Result.fail(Result.FAIL, "组织类型编码不可为空");
            }
            if (StringUtils.isEmpty(orgInfoAddDto.getOrgCode())) {
                log.info("据组织编码查询组织数据失败,参数非法{}", orgInfoAddDto.getOrgCode());
                return Result.fail(Result.FAIL, "组织编码不可为空");
            }
            //根据组织编码查询组织数据
            OrgInfoVo orgInfoVo = orgInfoService.selectOrgInfo(orgInfoAddDto);

            return new Result(Result.SUCCESS, "根据组织编码查询组织数据成功",orgInfoVo);
        } catch (Exception e) {
            LOGGER.error("Route==>OrgInfoController method=>selectOrgInfo 根据组织编码查询组织数据异常，入参：{}，异常：{}", Json.toJsonString(orgInfoAddDto), e);
            return handleException(e);
        }
    }

    /**
     * 根据组织编码修改组织数据
     * @param orgInfoAddDto
     * @return
     */
    @PostMapping("/updateOrgInfo")
    public Result updateOrgInfo(HttpServletRequest httpServletRequest, @RequestBody OrgInfoAddDto orgInfoAddDto) {
        log.info("Route=>OrgInfoController method=>updateOrgInfo 根据组织编码修改组织数据：{}", Json.toJsonString(orgInfoAddDto));
        try {
            // todo  wjy  临时获取companyCode和userCode方法
            String companyCode = httpServletRequest.getHeader(Constants.COMPANY_CODE);
            //String userCode = httpServletRequest.getHeader(Constants.USER_CODE);
            String userName = (String) httpServletRequest.getSession().getAttribute("userName");
            companyCode = "000001";
            //userCode = "001001";
            userName = "wjy";

            if (StringUtils.isEmpty(companyCode)) {
                log.warn("Route=>OrgInfoController method=>updateOrgInfo 根据组织编码修改组织数据，当前登录人归属租户信息异常");
                return Result.failWithMsg("登录人归属租户信息异常");
            }
            /*if (StringUtils.isEmpty(userCode)) {
                log.warn("Route=>OrgInfoController method=>updateOrgInfo 根据组织编码修改组织数据，当前登录人信息异常");
                return Result.failWithMsg("登录人信息异常");
            }*/
            if (StringUtils.isEmpty(userName)) {
                log.warn("Route=>OrgInfoController method=>updateOrgInfo 根据组织编码修改组织数据，当前登录人信息异常");
                return Result.failWithMsg("登录人信息异常");
            }
            orgInfoAddDto.setCompanyCode(companyCode);
            orgInfoAddDto.setCreatePerson(userName);

            if (StringUtils.isEmpty(orgInfoAddDto.getOrgCode())) {
                log.info("根据组织编码修改组织数据失败,参数非法{}", orgInfoAddDto.getOrgCode());
                return Result.fail(Result.FAIL, "组织编码不可为空");
            }
            if (CollectionUtils.isNotEmpty(orgInfoAddDto.getExtendData())) {
                //"1" 修改
                Result msg = verifyExtendData(orgInfoAddDto, "1");
                if (msg.getCode() == 9) {
                    log.info("根据组织编码修改组织数据失败,参数非法{}:::" + msg.getMsg(), orgInfoAddDto.getExtendData());
                    return Result.fail(Result.FAIL, msg.getMsg());
                }
            }
            //根据组织编码修改组织数据
            orgInfoService.updateOrgInfo(orgInfoAddDto);

            return new Result(Result.SUCCESS, "根据组织编码修改组织数据成功");
        } catch (Exception e) {
            LOGGER.error("Route==>OrgInfoController method=>updateOrgInfo 根据组织编码修改组织数据异常，入参：{}，异常：{}", Json.toJsonString(orgInfoAddDto), e);
            return handleException(e);
        }
    }

    /**
     * 组织移动
     * 只能进行同层级移动(因为编码规则已经确定)
     * @param orgInfoAddDto
     * @return
     */
    @PostMapping("/moveOrg")
    public Result moveOrg(HttpServletRequest httpServletRequest,@RequestBody OrgInfoAddDto orgInfoAddDto) {
        log.info("Route=>OrgInfoController method=>moveOrg 组织移动：{}", Json.toJsonString(orgInfoAddDto));
        try {
            // todo  wjy  临时获取companyCode和userCode方法
            String companyCode = httpServletRequest.getHeader(Constants.COMPANY_CODE);
            //String userCode = httpServletRequest.getHeader(Constants.USER_CODE);
            String userName = (String) httpServletRequest.getSession().getAttribute("userName");
            companyCode = "000001";
            //userCode = "001001";
            userName = "wjy";

            if (StringUtils.isEmpty(companyCode)) {
                log.warn("Route=>OrgInfoController method=>moveOrg 组织移动，当前登录人归属租户信息异常");
                return Result.failWithMsg("登录人归属租户信息异常");
            }
            /*if (StringUtils.isEmpty(userCode)) {
                log.warn("Route=>OrgInfoController method=>moveOrg 组织移动，当前登录人信息异常");
                return Result.failWithMsg("登录人信息异常");
            }*/
            if (StringUtils.isEmpty(userName)) {
                log.warn("Route=>OrgInfoController method=>moveOrg 组织移动，当前登录人信息异常");
                return Result.failWithMsg("登录人信息异常");
            }
            orgInfoAddDto.setCompanyCode(companyCode);
            orgInfoAddDto.setCreatePerson(userName);

            //将要移动的层级
            if (StringUtils.isEmpty(orgInfoAddDto.getOrgCode())) {
                log.info("组织移动失败,参数非法{}", orgInfoAddDto.getOrgCode());
                return Result.fail(Result.FAIL, "将要移动的组织编码不可为空");
            }
            //目标层级
            if (StringUtils.isEmpty(orgInfoAddDto.getOrgParentCode())) {
                log.info("组织移动失败,参数非法{}", orgInfoAddDto.getOrgParentCode());
                return Result.fail(Result.FAIL, "目标层级组织编码不可为空");
            }
            //根据组织编码获取对应层级
            int level = orgInfoService.verifyLevel(orgInfoAddDto.getOrgCode(), companyCode);
            //校验组织移动是否为同级移动
            if (level != (orgInfoAddDto.getOrgLevel() + 1)) {
                log.info("组织移动失败,参数非法{}", orgInfoAddDto.getOrgLevel());
                return new Result(Result.FAIL, "只能平级移动");
            }
            //组织移动
            orgInfoService.moveOrg(orgInfoAddDto);
            log.info("组织移动成功", Json.toJsonString(orgInfoAddDto));
            return new Result(Result.SUCCESS, "组织移动成功");
        } catch (Exception e) {
            LOGGER.error("Route==>OrgInfoController method=>moveOrg 组织移动异常，入参：{}，异常：{}", Json.toJsonString(orgInfoAddDto), e);
            return handleException(e);
        }
    }





}